import 'package:demo1223/model/twolist.dart';
import 'package:flutter/material.dart';
import 'package:provide/provide.dart';
import '../provide/classification_list.dart';
import './two_list/goodslists.dart';
import 'package:flutter_easyrefresh/easy_refresh.dart';



class Classification extends StatelessWidget {
  final String id1;
  final String id2;
  List<GoodData> data;
  Classification(this.id1,this.id2);
  
  @override
  Widget build(BuildContext context) {
    print(id1);
    print(id2);
    return Scaffold(
      appBar: AppBar(
                  leading: IconButton(
            icon: Icon(Icons.arrow_back),
            onPressed: () {
              Navigator.pop(context);
              print(data);
              print("0000000000000000000000000000000000000");
            },
          ),
        title: Text(
          '商品列表'
        ),
      ),
      body:  FutureBuilder(
          future: _getGoodlist(context),
          builder: (context, snapshot) {
            if (snapshot.hasData) {
              return Container(
                child: TwoGoodlist(id1:id1,id2:id2,goodlist: data,)
              );
            } else {
              return Text('加载中');
            }
          },
        ),
    );
  }
    Future _getGoodlist(BuildContext context) async {
    await Provide.value<Goodslist>(context).getgoodlist(id1,id2,1);
    data = Provide.value<Goodslist>(context).goodlitsData;
    print(data);
    print("===========================================================");
    return '完成加载';
  }
}

